<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var transpose = function(matrix) {
				let m = matrix.length;
				let n = matrix[0].length;
				let dist = new Array(n).fill(0).map(() => new Array(m).fill(0));
				for (let i = 0; i < m; i++) {
					for (let j = 0; j < n; j++) {
						dist[j][i] = matrix[i][j];
					}
				}
				return dist;
			};
			console.log(transpose([
				[1, 2, 3],
				[4, 5, 6],
				[7, 8, 9]
			]));
		</script>
	</body>
</html>
